// Decompiled by Jad v1.5.7g. Copyright 2000 Pavel Kouznetsov.
// Jad home page: http://www.geocities.com/SiliconValley/Bridge/8617/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi 
// Source File Name:   Leave.java

package com.oa.hr;

import com.oa.database.*;
import com.oa.util.Format;
import java.io.PrintStream;
import java.sql.*;
import java.util.HashMap;
import java.util.Vector;

public class Leave
{

    private HashMap hashMap;
    private String str_error;
    private DataConn dataConn;
    private QueryData queryData;
    private Format format;
    private ResultSet rs;
    private PreparedStatement pstmt;
    private String sTable;
    private String sField;
    private String sCond;
    private String sql;

    public Leave()
    {
        hashMap = null;
        str_error = "";
        dataConn = null;
        queryData = null;
        format = null;
        rs = null;
        pstmt = null;
        sTable = "";
        sField = "";
        sCond = "";
        sql = "";
        dataConn = new DataConn();
        queryData = new QueryData(dataConn);
        format = new Format();
    }

    public Leave(DataConn dataConnection)
    {
        hashMap = null;
        str_error = "";
        dataConn = null;
        queryData = null;
        format = null;
        rs = null;
        pstmt = null;
        sTable = "";
        sField = "";
        sCond = "";
        sql = "";
        dataConn = dataConnection;
        queryData = new QueryData(dataConn);
        format = new Format();
    }

    public boolean addLeave(String strMonth, int iQJLX, int iBasicId)
    {
        sql = "insert into OA_YG_KQQJTS(QJRQ,QJLX,QJRY)values(?,?,?)";
        try
        {
            pstmt = dataConn.getConnection().prepareStatement(sql);
            pstmt.setString(1, strMonth);
            pstmt.setInt(2, iQJLX);
            pstmt.setInt(3, iBasicId);
            pstmt.executeUpdate();
            pstmt.close();
        }
        catch(Exception exception) { }
        return true;
    }

    public int getLeaveCount(String strMonth, int iQJLX, int iBasicId)
    {
        int leaveCount = 0;
        sql = " select count(QJID) AS num from OA_YG_KQQJTS where QJRQ='" + strMonth + "' and QJLX=" + iQJLX + " and QJRY=" + iBasicId;
        try
        {
            pstmt = dataConn.getConnection().prepareStatement(sql);
            rs = pstmt.executeQuery();
            if(rs.next())
                leaveCount = rs.getInt("num");
            pstmt.close();
        }
        catch(Exception exception) { }
        return leaveCount;
    }

    public Vector getLeaveInfor(int iQJLX)
    {
        Vector vect = new Vector();
        sql = " select QJRQ,QJRY AS num from OA_YG_KQQJTS where QJLX=" + iQJLX + " group by QJRQ,QJRY";
        try
        {
            pstmt = dataConn.getConnection().prepareStatement(sql);
            for(rs = pstmt.executeQuery(); rs.next(); vect.add(rs.getString(2)))
                vect.add(rs.getString(1));

            pstmt.close();
        }
        catch(Exception exception) { }
        return vect;
    }

    public boolean deleteLeave(String strMonth)
    {
        sTable = "OA_YG_KQQJTS";
        sCond = "QJRQ='" + strMonth + "'";
        DeleteData deleteData = new DeleteData(dataConn);
        return deleteData.delete(sTable, sCond) != 0;
    }

    public static void main(String args[])
    {
        DataConn dataConn = new DataConn();
        Leave leave1 = new Leave(dataConn);
        Vector vect = leave1.getLeaveInfor(1);
        System.out.println("size=" + vect.size());
    }
}
